package com.clothing.customization.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 服装款式实体类
 */
@Data
@Entity
@Table(name = "tb_clothing_style")
@Schema(description = "服装款式实体")
public class ClothingStyle {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "款式ID")
    private Long id;
    
    @NotBlank(message = "款式名称不能为空")
    @Size(max = 50, message = "款式名称长度不能超过50个字符")
    @Schema(description = "款式名称")
    @Column(nullable = false, length = 50)
    private String name;
    
    @Size(max = 500, message = "描述长度不能超过500个字符")
    @Schema(description = "款式描述")
    @Column(columnDefinition = "LONGVARCHAR")
    private String description;
    
    @NotNull(message = "分类ID不能为空")
    @Schema(description = "分类ID")
    private Integer categoryId;
    
    @Transient
    @Schema(description = "分类名称")
    private String categoryName;
    
    @Schema(description = "缩略图URL")
    @Column(length = 255)
    private String thumbnail;
    
    @Schema(description = "状态：1-启用，0-禁用")
    @Column(nullable = false)
    private Integer status = 1;
    
    @CreationTimestamp
    @Column(name = "create_time", updatable = false)
    @Schema(description = "创建时间")
    private LocalDateTime createTime;
    
    @UpdateTimestamp
    @Schema(description = "更新时间")
    @Column(name = "update_time")
    private LocalDateTime updateTime;
    
    @Transient
    @Schema(description = "相关图片列表")
    private List<StyleImage> images;
    
    @PrePersist
    public void prePersist() {
        if (status == null) {
            status = 1;
        }
    }
} 